package org.yeph.sources;import org.apache.flink.api.java.tuple.Tuple2;import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;import java.util.Random;import java.util.regex.Pattern;public class BusinessDataSource extends RichParallelSourceFunction<Tuple2<String, Integer>> {    private volatile boolean running = true;    private static final String[] goods = {"A", "B", "C", "D"};    private static final Random random = new Random();    @Override    public void run(SourceContext<Tuple2<String, Integer>> ctx) throws Exception {        int count = 0;        while (running) {            Tuple2<String, Integer> tmp = Tuple2.of(goods[random.nextInt(4)], random.nextInt(100) + 1);            ctx.collect(tmp);            Thread.sleep(100);//            if (++count > 100) {//                cancel();//            }        }    }    @Override    public void cancel() {        running = false;    }}